package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;


import com.mall.shopping.NaviService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.PanelContentDto;
import com.mall.shopping.dto.PanelContentResponse;
import com.mall.user.annotation.Anoymous;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j  //获取log用来向日志中输入信息
@RestController
@Api(tags = "NavigationController", description = "导航栏显示")

public class NavigationController {
    //TODO:调用微服务
    @Reference(timeout = 3000,check = false)
    NaviService naviService;

    @GetMapping("shopping/navigation")
    //TODO:显示
    @Anoymous
    public ResponseData navigation(){
        PanelContentResponse panelContentResponse = naviService.queryPanelContent();
        if(!panelContentResponse.getCode().equals(ShoppingRetCode.SUCCESS.getCode())){
            return new ResponseUtil<>().setErrorMsg(panelContentResponse.getMsg());
        }
        return new ResponseUtil<List<PanelContentDto>>().setData(panelContentResponse.getPanelContentDtoList(),
                panelContentResponse.getMsg());
    }


    }


